from django.db import models

# Create your models here.
class Poet(models.Model):
    SEX = ((1,'hanzi'),(2,'女'))
    DYNASTY = ((1,'唐'),(2,'宋'),(3,'元'),(4,'清'))
    #  t_poet<name, sex, dynasty>
    name = models.CharField(max_length=20)
    sex = models.IntegerField(choices=SEX)
    dynasty = models.IntegerField(choices=DYNASTY)
    class Meta:
        db_table = 't_poet'

    def __str__(self):
        return self.name


class Poem(models.Model):
    title = models.CharField(max_length=100)
    content = models.CharField(max_length=1000)
    author = models.ForeignKey(Poet, on_delete=models.CASCADE, null=True, related_name='author')
    reviewers = models.ManyToManyField(Poet, related_name='reviewer')
    def __str__(self): 
        return self.title
    
    class Meta:
        db_table = 't_poem'